<?php

namespace App\Providers;

use App\Models\User;
use App\Services\Common\LengthAwarePaginatorService;
use Illuminate\Contracts\Cache\Repository;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use PHPOpenSourceSaver\JWTAuth\Providers\Storage\Illuminate;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        // 修改JWT为独立驱动
        $this->app->when(Illuminate::class) //use Tymon\JWTAuth\Providers\Storage\Illuminate
        ->needs(Repository::class)  //use Illuminate\Contracts\Cache\Repository
        ->give(function () {
            return app('cache')->store('jwt');
        });
        $this->app->bind('Illuminate\Pagination\LengthAwarePaginator',function ($app,$options){
            return new LengthAwarePaginatorService($options['items'], $options['total'], $options['perPage'], $options['currentPage'] , $options['options']);
        });
    }


    public function boot()
    {

    }
}
